home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJLSR111.ZIP / libsrc / c / gen / ftime.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  581b  |  28 lines

  1. /*
  2.   (c) Copyright 1992 Eric Backus
  3.  
  4.   This software may be used freely so long as this copyright notice is
  5.   left intact.  There is no warrantee on this software.
  6. */
  7.  
  8. #include <sys/time.h>
  9. #include <sys/timeb.h>
  10.  
  11. extern int    gettimeofday(struct timeval *, struct timezone *);
  12.  
  13. int
  14. ftime(struct timeb *tp)
  15. {
  16.     struct timeval tv;
  17.     struct timezone tz;
  18.  
  19.     if (gettimeofday(&tv, &tz) < 0) return -1;
  20.  
  21.     tp->time = tv.tv_sec;
  22.     tp->millitm = tv.tv_usec / 1000;
  23.     tp->timezone = tz.tz_minuteswest;
  24.     tp->dstflag = tz.tz_dsttime;
  25.  
  26.     return 0;
  27. }
  28.